$(function () {
    $('.btn_register').click(function () {
        var phone = $("[name='phone']").val();
        var nick_name = $("[name='nick_name']").val();
        var password = $("[name='password']").val();
        var re_password = $("[name='re_password']").val();
        if (phone.length != 11) {
            alert('请输入正确的手机号!');
            return;
        } else if (password.length < 6) {
            alert('密码至少有6位!');
            return;
        } else if (password != re_password) {
            alert('两次输入密码不一致！');
            return;
        } else {
            var params = {
                'phone': phone,
                'nick_name': nick_name,
                'password': password
            };
            $.ajax({
                url: "/passport/register_verify",
                type: "post",
                data: JSON.stringify(params),
                contentType: "application/json",
                success: function (resp) {
                    if (resp.errno == "0") {
                        location.href = '/'
                    } else {
                        alert(resp.errmsg)
                    }
                }
            })
        }
    })


});